<?php 
class Country_Model_Song extends Core_Model_Item_Abstract{
    
    private $_song = null;
    
    
    public function getRichContent($view = false, $params = array())
    {
        $playlist = null;
        $videoEmbedded = '';
    
        // $view == false means that this rich content is requested from the activity feed
        if( $view == false ){
          
          $desc   = "<div class='music_desc'></div>";
          $zview  = Zend_Registry::get('Zend_View');
          $zview->playlist     = $this;
          $zview->song        = $this;
          $zview->short_player = true;
          $videoEmbedded       = $desc . $zview->render('application/modules/Country/views/scripts/_Player.tpl');
        }
        
        return $videoEmbedded;
    }
    
    public function getPlayListSong(){
        if ($this->_song != null) return $this->_song;
        
        $song = Engine_Api::_()->getItem('music_playlist_song',$this->s_id);
        $this->_song = $song;
        return $song;
    }
    public function comments()
    {
        $song = $this->getPlayListSong();
        if (empty($song)) return null;
        return new Engine_ProxyObject($song, Engine_Api::_()->getDbtable('comments', 'core'));
    }

    /**
    * Gets a proxy object for the like handler
    *
    * @return Engine_ProxyObject
    * */
    public function likes()
    {
        $song = $this->getPlayListSong();
        if (empty($song)) return null;
        return new Engine_ProxyObject($song, Engine_Api::_()->getDbtable('likes', 'core'));
    }
    
    /**
    * Gets a proxy object for the tags handler
    *
    * @return Engine_ProxyObject
    * */
    public function tags()
    {
        $song = $this->getPlayListSong();
        if (empty($song)) return null;
        return new Engine_ProxyObject($song, Engine_Api::_()->getDbtable('tags', 'core'));
    }
    
    public function authorization($adapter = null)
    {
        return $this;
        return new Engine_ProxyObject($this, $object);
    }
    
    public function  isAllowed($role,$action){
        $auth = Engine_Api::_()->authorization()->context;
        return   $auth->isAllowed($this, $role, $action);
    
    }
                    
  
}
?>